<template>
  <div class="my-order">
    <div class="orderTable">
      <ul class="order-table-header">
        <li class="order-li">礼品信息</li>
        <li class="order-li">兑换码豆</li>
        <li class="order-li">数量</li>
        <li class="order-li">物流公司</li>
        <li class="order-li">物流单号</li>
        <li class="order-li">备注/兑换码</li>
        <li class="order-li">订单状态</li>
      </ul>
      <div class="order-table-list" v-if="!noDataStatus">
        <div class="order-table-message" v-for="(list, index) in myOrderData" :key="index">
          <div class="order-table-message-header">
            <p class="order-create-time">创建时间: {{ list.addTime }}</p>
            <p class="order-number">订单号: {{ list.orderUuid }}</p>
          </div>
          <div class="order-table-context">
            <ul class="order-context-ul" v-for="(item,ide) in list.orderProductDetailVOList" :key="ide">
              <li class="order-context-li">
                <div class="commodityImg">
                  <img :src="item.coverImg" alt="">
                </div>
                <div class="commodity-text">
                  <h2>{{ item.name }}</h2>
                  <p>{{ item.versionDescription }}</p>
                </div>
              </li>
              <li class="order-context-li">
                <p class="my-number">{{ item.coin }}豆</p>
              </li>
              <li class="order-context-li">
                <p class="my-number">{{ item.total }}</p>
              </li>
              <!-- <li class="order-context-li">
                <p class="my-number">{{ item.delivery.mailCompany }}</p>
              </li>
              <li class="order-context-li">
                <p class="my-number">{{ item.delivery.mailNumber }}</p>
              </li>
              <li class="order-context-li">
                <p class="my-number">{{ item.productRemark }}</p>
              </li>
              <li class="order-context-li">
                <p class="my-number">{{ item.statusDesc }}</p>
              </li> -->
            </ul>
          </div>
        </div>
      </div>
      <slot name="myOrderNoData" v-else></slot>
    </div>
    <el-pagination
      v-if="!noDataStatus"
      background
      :hide-on-single-page="true"
      class="pagination"
      layout="prev, pager, next, jumper"
      :page-size="page.size"
      :total="page.total"
      @current-change="getCommodityList"
    />
  </div>
</template>

<script>
import { getMyOrderList } from '~/api/pointsMall/commodity.js'
export default {
  data() {
    return {
      page: {
        current: 1,
        size: 8,
        total: 0
      },
      myOrderData: [],
      noDataStatus: false
    }
  },
  mounted() {
    this.getMyOrderData()
  },
  methods: {
    getMyOrderData() {
      getMyOrderList(this.page).then((res) => {
        if (res.code === 200) {
          this.page.total = res.data.total
          this.page.total === 0 ? this.noDataStatus = true : this.noDataStatus = false
          this.myOrderData = res.data.orderProductDetailVOList
        }
      })
    },
    getCommodityList(val) {
      this.page.current = val
      this.getMyOrderData()
    }
  }
}
</script>

<style scoped lang="scss">
.my-order {
  text-align: center;
  .orderTable {
    padding-bottom: 15px;
    box-sizing: border-box;
    .order-table-header {
      width: 100%;
      height:65px;
      background: rgba(253, 159, 1, 1);
      display: flex;
      flex-direction: row;
      align-items: center;
      .order-li {
        width: 120px;
        line-height:65px;
        text-align: center;
        font-size: 14px;
        color:#fff;
        &:nth-of-type(3) {
          width:80px;
        }
        &:nth-of-type(5) {
          width:190px;
        }
        &:first-child {
          width: 300px;
        }
      }
    }
    .order-table-list {
      .order-table-message {
        margin-top:15px;
        border: 1px solid #e7e7e7;
        border-top:none;
        .order-table-message-header{
          height: 30px;
          line-height: 30px;
          padding: 0 24px;
          box-sizing: border-box;
          background-color: #f2f2f2;
          display: flex;
          flex-direction: row;
          align-items: center;
          margin-top: 15px;
          .order-create-time {
            font-size: 14px;
            color: #666;
            margin-right: 50px;
          }
          .order-number {
            font-size: 14px;
            color: #666;
            margin-right: 50px;
          }
        }
        .order-table-context {
          .order-context-ul {
            display: flex;
            flex-direction: row;
            align-items: center;
            padding:15px 0;
            box-sizing: border-box;
            border-bottom:1px solid #e7e7e7;
            .order-context-li {
              width: 120px;
              display: flex;
              flex-direction: row;
              align-items: center;
              justify-content: center;
              padding-left:15px;
              box-sizing: border-box;
              .commodityImg {
                width: 120px;
                img {
                  width: 100%;
                  max-width:100px;
                  height:auto;
                  display: block;
                }
              }
              .commodity-text {
                padding-left: 12px;
                box-sizing: border-box;
                width: 196px;
                display: inline-block;
                padding-right: 10px;
                h2 {
                  font-size: 16px;
                  color: #333;
                  font-weight: normal;
                  text-overflow: ellipsis;
                  overflow: hidden;
                  text-align: left;
                  white-space: nowrap;
                }
                p {
                  font-size: 14px;
                  color: #666;
                  text-align: left;
                }
              }
              .my-number {
                font-size: 14px;
                color:#666;
                word-break: break-all;
              }
              &:nth-of-type(3) {
                width:80px;
              }
              &:nth-of-type(5) {
                width:190px;
              }
              &:first-child {
                width:300px;
                justify-content: start;
              }
            }
            &:last-child {
              border:none;
            }
          }
        }
      }
    }
  }
}
</style>
